import { requestClient } from '#/api/request';

export namespace DictDataApi {
  export interface DictData {
    [key: number]: any;
    dictId: number;
    dictCode: string;
    dictName: string;
    DictDataCode: string;
    DictDataName: string;
    pDictCode: string;
    pDictName: string;
    table: string;
    seq: number;
    memo: string;
    status: 0 | 1;
    createdTime: string;
    createdBy: string;
    lastUpdateTime: string;
    lastUpdateBy: string;
  }
}

/**
 * 获取字典类型分页列表数据
 */
async function gridDictData(query: DictDataApi.DictData) {
  return requestClient.post<Array<DictDataApi.DictData>>(
    '/system/dict/dictdata/grid',
    query,
  );
}
/**
 * 获取字典类型列表数据
 */
async function listDictData(query: DictDataApi.DictData) {
  return requestClient.post<Array<DictDataApi.DictData>>(
    '/system/dict/dictdata/list',
    query,
  );
}
/**
 * 创建字典类型
 * @param data 字典类型数据
 */
async function createDictData(data: Omit<DictDataApi.DictData, 'dictId'>) {
  return requestClient.post('/system/dict/dictdata/save', data);
}

/**
 * 更新字典类型
 *
 * @param id 字典类型 ID
 * @param data 字典类型数据
 */
async function updateDictData(data: DictDataApi.DictData) {
  return requestClient.put(`/system/dict/dictdata/modiftyDict`, data);
}

/**
 * 删除字典类型
 * @param id 字典类型 ID
 */
async function deleteDictData(id: number) {
  return requestClient.post(`/system/dict/dictdata/remove`, { dictId: id });
}

export {
  createDictData,
  deleteDictData,
  gridDictData,
  listDictData,
  updateDictData,
};
